package com.cjm.algorithm.dp;

public class Ti718 {
    public static void main(String[] args) {

    }
    public int findLength(int[] nums1, int[] nums2) {
        int[] dp = new int[nums2.length + 1];
        int res = 0;
        for (int i = 1; i < nums1.length+1; i++) {
            for (int j = nums2.length; j > 0; j--) {
                if (nums1[i-1] == nums2[j-1]) {
                    dp[j] = dp[j - 1] + 1;
                } else {
                    dp[j] = 0;
                }
                res = dp[j] > res?dp[j]:res;
            }
        }
        return res;
    }
}
